﻿using Microsoft.Xna.Framework;

namespace HumanElement.Xna.Core
{
    public static class TranslateExtensions
    {
        /// <summary>
        /// Moves to.
        /// </summary>
        /// <typeparam name="TTranslate">The type of the translate.</typeparam>
        /// <param name="t">The t.</param>
        /// <param name="position">The position.</param>
        public static void MoveTo<TTranslate>(this TTranslate t, Vector3 position) where TTranslate : ITranslate
        {
            t.WorldMatrix = Matrix.CreateTranslation(position);
        }

        /// <summary>
        /// Translates the specified t.
        /// </summary>
        /// <typeparam name="TTranslate">The type of the translate.</typeparam>
        /// <param name="t">The t.</param>
        public static void Translate<TTranslate>(this TTranslate t) where TTranslate : ITranslate
        {
            t.WorldMatrix = Matrix.CreateWorld(t.Position, t.Forward, t.Up);
        }

        /// <summary>
        /// Looks at.
        /// </summary>
        /// <typeparam name="TTranslate">The type of the translate.</typeparam>
        /// <param name="t">The t.</param>
        /// <param name="target">The target.</param>
        public static void LookAt<TTranslate>(this TTranslate t, Vector3 target) where TTranslate : ITranslate
        {
            var mat = Matrix.CreateLookAt(t.Position, target, t.Up);

            Vector3 pos, sca;
            Quaternion rot;

            mat.Decompose(out sca, out rot, out pos);

            
        }
    }
}